import type { App } from 'vue'

export default (app: App<Element>) => {
  const importDirectives = import.meta.glob('@/directives/*.ts')
  // Object.entries不会遍历原型链中的属性，for…in会
  for (const [path, fn] of Object.entries(importDirectives)) {
    fn().then((module: any) => {
      const names = path.split('/')
      let name = names[names.length - 1]
      name = name.substring(0, name.length - 3)
      app.directive(name, module.default)
    })
  }
}
